<?php

namespace app\common\model\task;

use app\admin\model\Preproduct;
use think\Model;

class Detail extends Model
{
    // 表名
    protected $name = 'finance_extract_task_detail';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'pro_name',
        'pro_img',
        'type_text'
    ];

    public function getProNameAttr($value, $data)
    {
        $pre = Preproduct::get($data['pro_id']);
        return $pre['cname'];
    }
    public function getProImgAttr($value, $data)
    {
        $pre = Preproduct::get($data['pro_id']);
        return $pre['image'];
    }

    public function getTypeTextAttr($value, $data)
    {
        $array = [1=>'样书',2=>'赠书'];
        return $array[$data['type']];
    }

}
